package wangle.com.testtinker;

import android.os.Handler;
import android.os.Message;

import com.tinkerpatch.sdk.TinkerPatch;

/**
 * Created by Administrator on 2017/2/8.
 */

public class FatchPatchHandler extends Handler{
    public static final long HOUR_INTERVAL = 3600 * 1000;

    private long checkInterval;


    public void fetchPatchWithInterval( int hour ){
        //设置Tinker时间间隔
        TinkerPatch.with().setFetchDynamicConfigIntervalByHours(hour);

        checkInterval = hour * HOUR_INTERVAL;

        sendEmptyMessage(0);

    }

    @Override
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
        TinkerPatch.with().fetchPatchUpdate(false);
        sendEmptyMessageDelayed(0, checkInterval + 10 * 60 * 1000);
    }
}
